<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en" class="no-js" id="ng-app">
<head>
<meta charset="UTF-8">
<jsp:include page="/includes/common/head.jsp" />
<title>CS4280 BOOKSTORE</title>
</head>
<body>
	<div data-flex-background-src="${ baseURL }/assets/img/background.jpg"
		flex-background></div>
	<jsp:include page="/includes/header.jsp">
		<jsp:param name="currentUser" value="${currentUser}" /><jsp:param name="baseURL" value="${ baseURL }" />
		
	</jsp:include>
	<section id="mainContent">
		<c:if test="${action == null}">
			<form method="POST" action="${ baseURL }/register">
				<ul>
					<li><label>Username: </label> <input type="text"
						name="username" required="required" /></li>
					<li><label>Password: </label> <input type="password"
						name="password" required="required" /></li>
					<li><label>Password: </label> <input type="password"
						name="password_repeat" required="required" /></li>
					<li><label>Email: </label><input type="text" name="email"
						required="required" /></li>
					<li><label>Telephone No: </label><input type="text" name="telephone"
						required="required" /></li>
				</ul>
				<input type="submit" value="Register" /> <input type="hidden"
					name="action" value="new" />
			</form>
		</c:if>

		<c:if test="${action == 'succeeded'}">
			<p>Registration Succeeded. You may visit:</p>
			<a href="${ baseURL }/home">Home Page</a>
			<br />
			<a href="${ baseURL }/member">Member Center</a>
			<br />
		</c:if>

		<c:if test="${action == 'failed'}">
			<form method="POST" action="${ baseURL }/register">
				<c:if test="${isNameUsed}">
					<span class="form-error">Username is used by other. Please
						try another one.</span><br />
				</c:if>
				<c:if test="${isPwdNotMatched}">
					<span class="form-error">Values in Two Password fields are
						not matched Please try again.</span><br />
				</c:if>
				<c:if test="${isEmailUsed}">
					<span class="form-error">Email is used by other. Please try
						another one.</span><br />
				</c:if>
				<c:if test="${isTelNotInt}">
					<span class="form-error">Telephone is not a number. Please try again.</span><br />
				</c:if>
				
				<ul>
					<li><label>Username: </label> <input type="text" name="username"
						required="required" value="${ user.username }" /></li>
					<li><label>Password: </label> <input type="password"
						name="password" required="required" value="" /></li>
					<li><label>Password: </label> <input type="password"
						name="password_repeat" required="required" value="" /></li>
					<li><label>Email: </label><input type="text" name="email"
						required="required" value="${ user.email }" /></li>
					<li><label>Telephone No: </label><input type="text" name="telephone"
						required="required" /></li>
				</ul>
				<input type="submit" value="Register" /> <input type="hidden"
					name="action" value="new" />
			</form>
		</c:if>
	</section>
</body>
</html>